package com.daiqee.service.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.daiqee.pojo.ProcureOrderCheckInfo;
import com.daiqee.pojo.ProcurementPlan;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.daiqee.dao.mapper.ProcureOrderCheckInfoMapper;

/**
 * 订单审核信息
 * 
 * <br/>
 * @since JDK 1.8
 * @version  V2.1
 * @author RichardTang 
 * @date: 2018年5月8日 上午8:25:02
 * @package com.daiqee.service.impl
 * @copyright:Copyright (c) 2018, 1245811923@qq.com All Rights Reserved.
 */
@Service
public class ProcureOriderCheckInfoService extends ServiceImpl<ProcureOrderCheckInfoMapper,ProcureOrderCheckInfo>{

	@Autowired
	private ProcureOrderCheckInfoMapper procureOrderCheckInfoMapper;
	
	@Autowired
	private ProcurementPlanService procurementPlanService;
	
	/**
	 * 添加采购计划审核信息
	 * @param info
	 * 			采购计划审核实体
	 * @return	true: 添加成功 false:添加失败
	 */
	public Boolean addProcureOrderInfo(ProcureOrderCheckInfo info) {
		
		ProcurementPlan procurePlan = new ProcurementPlan();
		
		procurePlan.setProcurePlanId(info.getProcureOrderCheckProcureId());
		procurePlan.setProcurePlanCheckStatus(info.getProcureOrderCheckStatus());
		
		Integer flagId = Integer.parseInt(info.getProcureOrderCheckStatus());
		
		if(flagId==3) {//3代表审核通过状态
			procurePlan.setProcurePlanBuyerStatus("2");
		}else if(flagId==4||flagId==5) {//4代表不通过 5代表重新安排
			procurePlan.setProcurePlanBuyerStatus("1");
		}
		
		info.setProcureOrderCheckUpdate(new Date());
		
		procureOrderCheckInfoMapper.insert(info);
		
		Boolean flag = procurementPlanService.updateById(procurePlan);
		
		return flag;
	}
}
